from django.urls import path,re_path
from rest_framework.routers import DefaultRouter
from .djcontroller import StudentViewSerializer as DjangoStudentViewSerializer
from .djcontroller import StudentViewController as DjangoStudentViewController
from .djcontroller import SersStudentsView as DjangoSersStudentsView
router = DefaultRouter()# # 创建一个默认的路由器对象
# 第一个参数 "students2" 是路由前缀（对应 URL 中的路径）
# 第二个参数是你定义的视图集类
# basename 是在生成 URL 名称时使用的前缀
router.register("students", DjangoStudentViewSerializer.StudentModelViewSet, basename="students"),
router.register("students2", DjangoStudentViewSerializer.StudentModelViewSetDemo2, basename="students2"),
# 将 router 自动生成的 URL 添加到 urlpatterns 中
urlpatterns = [# 可以写其他的手动路径
    path('students3/', DjangoSersStudentsView.Student1View.as_view()),
    path('students4/', DjangoStudentViewController.StudentView.as_view()),  # class StudentView(View):
    re_path("^students4/(?P<pk>\d+)/$", DjangoStudentViewController.StudentInfoView.as_view()),
] + router.urls  # 把 DRF 自动生成的增删改查接口路径加进来
'''
urlpatterns = [
    path('student/', DjangoStudentViewController.StudentView.as_view()),# class StudentView(View):
    re_path("^student/(?P<pk>\d+)/$", DjangoStudentViewController.StudentInfoView.as_view()),
]'''
